package com.sskj.cndragon.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.cndragon.http.HttpConfig;
import com.sskj.cndragon.ui.activity.LoginActivity;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.MD5Util;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.bean.UserData;
import com.sskj.lib.http.JsonCallBack;


public class LoginActivityPresenter extends BasePresenter<LoginActivity> {

    public void login(String mobile, String pwd) {
        httpService.login(mobile, MD5Util.getMd5Value(pwd))
                .tag(this)
                .execute(new JsonCallBack<HttpData<UserData>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<UserData>> response) {
                        HttpData body = response.body();
                        ToastUtil.showShort(body.getMsg());
                        if (body.getStatus() == HttpConfig.OK) {
                            mView.loginSuccess((UserData) body.getData());
                        }
                    }
                });
    }
}
